package com.summer.scan;

import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;

public class PortScan {

	public static void main(String[] args) throws Exception {
//		Scanner sc=new Scanner(System.in);
//		System.out.print(name+"请输入你想要扫描的ip地址：");
//		String yid=sc.next();
//		System.out.print("请输入timeout时间");
//		int timeout=sc.nextInt();
		
		int timeout = 30;
		String yid = "admin.jyzf.cc";
		
		InetAddress ip = InetAddress.getByName(yid);
		System.out.println("开始扫描：");
		for(int i=0;i<=65535;i++) {
			try {
				    @SuppressWarnings("resource")
					Socket socket=new Socket();
					//实现与端口连接
				    socket.connect(new InetSocketAddress(ip, i), timeout);
					//判断端口连接状态
					if(socket.isBound()) 
					System.out.println(i+"端口是开放的");
				} catch (Exception e) {	
			}	
		}
		System.out.println("结束扫描");
	}
	
}
